package com.hzdaba.aiapi.configuration;

import lombok.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;

/**
 * 用于专门销毁线程池
 * 好像多此一举，直接用线程池本身的销毁方法不就可以了吗
 *
 * @author 刘逸晖
 */
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@ToString
@Getter
@Setter
@Builder
public class ThreadPoolDestroyer {

    /**
     * 预销毁的线程池
     */
    private ExecutorService executorService;

    /**
     * 日志对象
     */
    private static final Logger logger = LoggerFactory.getLogger(ThreadPoolDestroyer.class);

    /**
     * 销毁线程池
     */
    public void destroyThreadPool() {
        this.executorService.shutdown();
        logger.info("县城池已销毁");
    }

}
